﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace PTB2
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        private int a, b, c;
        public void HienThiChuongTrinh()
        {
            string result = "";
            if (a == 0 && b == 0 && c == 0)
            {
                result = "0";
            }
            if (a == 0 && b != 0 && c == 0)
            {
                result = b + "x";
            }
            if (a == 0 && b == 0 && c != 0)
            {
                result = "" + c;
            }
            if (a == 0 && b != 0 && c != 0)
            {
                result = b + "x+" + c;
            }
            if (a != 0 && b == 0 && c == 0)
            {
                result = a + "x^2";
            }
            if (a != 0 && b != 0 && c == 0)
            {
                result = a + "x^2+" + b + "x";
            }
            if (a != 0 && b == 0 && c != 0)
            {
                result = a + "x^2+" + c;
            }
            if (a != 0 && b != 0 && c != 0)
            {
                result = a + "x^2+" + b + "x+" + c;
            }
            lb2.Text = result;
        }
        void LayGiaTri() {
            string tam = tbx_a.Text;
            if (tam.Equals(""))
                this.a = 0;
            else
             this.a = int.Parse(tam);
            tam = tbx_b.Text;
            if (tam.Equals(""))
                this.b = 0;
            else
                b = int.Parse(tam);
            tam = tbx_c.Text;
            if (tam.Equals(""))
                this.c = 0;
            else
                c = int.Parse(tam);
        }

        public void GiaiPhuongTrinh() {
            if (a == 0 && b == 0 && c == 0)
            {
                delta.Text = "";
                loigiai.Text = "Phương trình có vô số nghiệm";
                x1.Text = "";
                x2.Text = "";
            }
            if (a == 0 && b != 0 && c == 0)
            {
                delta.Text = "";
                loigiai.Text = "Phương trình có 1 nghiệm";
                x1.Text = "0";
                x2.Text = "";
            }
            if (a == 0 && b == 0 && c != 0)
            {
                
            }
            if (a == 0 && b != 0 && c != 0)
            {
                
            }
            if (a != 0 && b == 0 && c == 0)
            {
                
            }
            if (a != 0 && b != 0 && c == 0)
            {
                
            }
            if (a != 0 && b == 0 && c != 0)
            { 
            }
            if (a != 0 && b != 0 && c != 0)
            {
               
            }
        }
        private void btn1_Click(object sender, EventArgs e)
        {
            LayGiaTri();
            HienThiChuongTrinh();
            GiaiPhuongTrinh();
        }
    }
}
